home *** CD-ROM | disk | FTP | other *** search
- Path: gryphon.phoenix.net!usenet
- From: brucew@phoenix.net (Bruce Wedding)
- Newsgroups: comp.lang.c
- Subject: Re: Is this ok: *pointer++ = value ??
- Date: Sat, 06 Jan 1996 21:14:38 GMT
- Organization: BranPaul Systems
- Message-ID: <4cmmcd$e3u@gryphon.phoenix.net>
- References: <4cklvv$nmm@alcor.usc.edu>
- NNTP-Posting-Host: dial15.phoenix.net
- X-Newsreader: Moe's Newsreader
-
- wawda@alcor.usc.edu (Abu Wawda) wrote:
-
- > for (i=0; i<50; i++) *pointer++ = i;
-
- >My only problem is why? I mean you aren't allowed to do:
-
- > for (i=0; i<50; i++) p++ = i;
-
- Sure you can do that. You are assigning addresses to the pointer. It
- probably isn't too smart, but it is legal.
-
- >Like you aren't supposed to be put anything like x+5 or some other
- >unsolved quantity on the left side for assignment. However, is this an
- >exception for pointers? I can understand doing it backwards as
- >perfectly legal:
-
- > int x;
- > x = *pointer++;
-
- >but not:
-
- > *pointer++ = x;
-
- There is nothing wrong with any of this. The only thing you can't put
- on the left is an R value which is something that can't be assigned to
- like 5, or an array. For example:
-
- You can't do this:
- int i = 0;
-
- 5 = i;
- but you can do:
- i = 5;
-
- You can't do:
- char *p, arr[30];
-
- arr = p;
- but you can do
- p = arr;
-
- Bruce
- Bruce D. Wedding Have Compiler, Will Travel!
- Perspicacious Programming Performed Promptly
- Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
-
-